package com.tongji.showroom.service
{	
	import com.tongji.showroom.events.GetUserSceneEvent;
	
	import flash.system.Security;
	
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.soap.WebService;
	
	import org.robotlegs.mvcs.Actor;
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/08/
	 */ 
	public class UserSceneService extends Actor
	{
		private var ws:WebService;

		public function UserSceneService()
		{
			super();
			ws = new WebService();
			ws.wsdl = "http://share.rryjw.com/VRService.asmx?wsdl";
			ws.useProxy = false;
			ws.loadWSDL();
			Security.loadPolicyFile("http://img.rryjw.com/crossdomain.xml");
		}

		/**获取用户发布的场景
		 * @author caddy
		 * @param userId
		 * @param currentPage
		 * @param pageSize
		 * 
		 */		
		public function getUserScene(userId:Number, state:int, currentPage:int, pageSize:int):void
		{
			ws.GetUserSceneByState(userId, 1,currentPage, pageSize);
			ws.GetUserSceneByState.addEventListener(ResultEvent.RESULT, getUserSceneResult);
			ws.GetUserSceneByState.addEventListener(FaultEvent.FAULT, faultHandler);
		}
		
		private function getUserSceneResult(event:ResultEvent):void
		{
			dispatch(new GetUserSceneEvent(GetUserSceneEvent.UPDATE_USER_SCENE, 0, 0, 0, 0, event.result as String));
		}
		
		private function faultHandler(event:FaultEvent):void
		{
			Alert.show("失败" + event.fault.toString());
		}
	}
}